package com.jvup.gameshow.view.attributeBinder;

import androidx.databinding.BindingAdapter;

import com.jvup.common.basic.ObjectUtil;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.youth.banner.Banner;
import com.youth.banner.adapter.BannerAdapter;

/**
 * 第三方控件属性扩展绑定适配器
 */
public class ThirdPartyViewAttrAdapter {

    @BindingAdapter("srlEnableRefresh")
    public static void setEnableRefresh(SmartRefreshLayout refreshLayout, Boolean enableRefresh) {
        if(refreshLayout != null && enableRefresh != null) {
            refreshLayout.setEnableRefresh(enableRefresh);
        }
    }

    @BindingAdapter("adapter")
    public static void setBannerAdapter(Banner banner, BannerAdapter adapter) {
        if(ObjectUtil.nonNull(adapter)) {
            banner.setAdapter(adapter);
        }
    }

    @BindingAdapter(value = {"galleryEffectWidthLeft", "galleryEffectWidthRight", "galleryEffectPageMargin", "galleryEffectScale"}, requireAll = false)
    public static void setBannerGalleryEffect(Banner banner, int galleryWidthLeft, int galleryWidthRight, int galleryPageMargin, float galleryScale) {
        banner.setBannerGalleryEffect(galleryWidthLeft, galleryWidthRight, galleryPageMargin, galleryScale);
    }

}
